package com.xx.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xx.entity.Products;
import com.xx.entity.ProductsList;
import com.xx.mapper.ProductsMapper;
import com.xx.service.ProductsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author myx
 * @since 2024-10-20
 */
@Service
public class ProductsServiceImpl implements ProductsService {
    @Autowired
    ProductsMapper productsMapper;

    @Override
    public ProductsList queryById(Integer productId) {
        return productsMapper.queryById(productId);
    }

    @Override
    public PageInfo<ProductsList> queryAllByLimit(Products products, Integer pageNum) {
        PageHelper.startPage(pageNum,5);
        List<ProductsList> list =  productsMapper.queryAllByLimit(products);
        PageInfo<ProductsList> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }


    @Override
    public int insert(Products products) {
        return productsMapper.insert(products);
    }

    @Override
    public int update(Products products) {
        return productsMapper.update(products);
    }

    @Override
    public int deleteById(Integer productId) {
        return productsMapper.deleteById(productId);
    }

    @Override
    public String selectImageUrl(Integer productId) {
        return productsMapper.selectImageUrl(productId);
    }

    @Override
    public Object queryByPage(Products products, Integer pageNum) {
        return null;
    }
}
